package com.zsy.service.impl;

import com.zsy.mapper.DeptMapper;
import com.zsy.pojo.Dept;
import com.zsy.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author: zhengsuyang
 * @Desc:
 * @create: 2025-09-10 16:01
 **/
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    /**
     * 查询部门
     *
     * @return
     */
    @Override
    public List<Dept> queryDeptList() {
        return deptMapper.queryDeptList();
    }

    /**
     * 根据id查询部门
     *
     * @param id
     * @return
     */
    @Override
    public Dept queryDeptById(Integer id) {
        return deptMapper.queryDeptById(id);
    }

    /**
     * 新增部门
     *
     * @param dept
     */
    @Override
    public void addDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.addDept(dept);
    }

    /**
     * 根据id修改部门
     *
     * @param dept
     */
    @Override
    public void updateDept(Dept dept) {
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.updateDept(dept);
    }

    /**
     * 根据id删除部门
     *
     * @param id
     */
    @Override
    public void deleteDeptById(Integer id) {
        deptMapper.deleteDeptById(id);
    }
}
